import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/login.vue'

Vue.use(VueRouter)

const routes = [
  // 路由重定向
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/Welcome',
    // 因为当某个路由有子级路由的时候，这时候父级路由需要一个默认的路由，所以父级路由不能定义name属性
    // name: 'Welcome',
    component: () => import(/* webpackChunkName: "Welcome" */ '../views/Welcome.vue'),
    children: [
      {
        path: '/',
        name: 'index',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/index.vue')
      },
      {
        path: '/users',
        name: 'users',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/user.vue')
      },
      {
        path: '/roles',
        name: 'roles',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/roles.vue')
      },
      {
        path: '/rights',
        name: 'rights',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/rights.vue')
      },
      {
        path: '/goods',
        name: 'goods',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/goods.vue'),
      },
      {
        path: '/params',
        name: 'params',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/params.vue')
      },
      {
        path: '/categories',
        name: 'categories',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/categories.vue')
      },
      {
        path: '/orders',
        name: 'orders',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/orders.vue')
      },
      {
        path: '/reports',
        name: 'reports',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/reports.vue')
      },
      {
        path: '/goods/add',
        name: 'add',
        component: () => import(/* webpackChunkName: "Welcome" */ '../views/add.vue'),
      }

    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
